package com.example.homemodule.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.homemodule.model.bean.ReBuyEntity;
import com.example.homemodule.R;

import java.util.List;

/**
 * Created by SHICHENG
 * <p>
 * Time on 2022/01/04
 */
public class DrugListAdapter extends BaseQuickAdapter<ReBuyEntity.DataBean, BaseViewHolder> {
    public DrugListAdapter(@Nullable List<ReBuyEntity.DataBean> data) {
        super(R.layout.item_drug_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ReBuyEntity.DataBean item) {
        helper.addOnClickListener(R.id.rebuy_alert_fast);
        Glide.with(mContext).load(item.getDrugUrl()).into((ImageView) helper.getView(R.id.drug_img));
        helper.setText(R.id.rebug_alert_name,item.getCommodityName());
        helper.setText(R.id.rebug_alert_spec,item.getSpec());
        helper.setText(R.id.rebug_alert_price,"￥"+item.getPrice());
        String s = "";
        if (item.getArticleQuantity()>0){
            s = "赠送：多媒体患教X"+item.getArticleQuantity();
            helper.setVisible(R.id.rebug_alert_articl,true);
        }
        if (item.getInquiryQuantity()>0){
            s = "\t\t赠送：免费问诊X"+item.getInquiryQuantity();
        }
        if (!TextUtils.isEmpty(s)){
            helper.setText(R.id.rebug_alert_articl,s);
            helper.setVisible(R.id.rebug_alert_articl,true);
        }else{
            helper.setVisible(R.id.rebug_alert_articl,false);
        }

    }
}
